<template>
    <div>
      <div class="list-top">
        <div class="list-top-left">
        <van-icon name="play-circle-o" size="0.5rem" />
        <span class="list-play">播放全部<span class="list-total">（共{{playList.length}}首）</span></span>
        </div>
        <div class="list-top-right">
            <van-button icon="plus" color="red" round type="primary">收藏({{subscribedCount}})</van-button>
        </div>
      </div>
      <div class="list-content">
        <div class="list-content-box" v-for="(item,index) in playList" :key="item.al.id" @click="handlePlaySong(index)">
            <div class="index-item">
                {{index+1}}
            </div>
            <div class="title-author">
                <div class="title">
                    {{item.name}}
                </div>
                <div class="author">
                    {{handleAr(item.ar)}}
                </div>
            </div>
            <div class="icons">
             <van-icon v-if="item.mv!==0" name="tv-o" size="0.5rem"/>   
            <van-icon name="wap-nav" size="0.5rem" />
            </div>
        </div>

      </div>
    </div>
</template>

<script lang="ts">
import {  useStore } from "vuex";
import {handleAr} from "@/utils/utils.js"
export default {
setup(props) {
    const store=useStore()
  
   
    function handlePlaySong(index){
      store.commit("changePlayList",props.playList)
store.commit("changePlayingSong",index)
     
        
    }
return {
    // getAllAuthor,
    handlePlaySong,
    handleAr,

};
},
props:["playList","subscribedCount"]
};
</script>

<style lang="less" scoped>
    .list-top{
        background-color: white;
        border-radius: 0.4rem;
    display:flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    .list-top-left{
        display: flex;
      
        margin-left: 0.3rem;
        
        .list-play{
            display: flex;
            align-items: center;
            justify-content: center;
            
        }
        .list-total{
            font-size: smaller;
            color: gray;
        }
    }
    .list-top-right{
        margin-top: 0.2rem;
        margin-right: 0.3rem;
    }
    }
    .list-content-box{
        padding: 0.2rem;
        display: flex;
        align-items: center;
        position: relative;
        .index-item{
            margin: 0.2rem;
            color: gray;
        }
        .title-author{

            .title{
                font-weight: bold;
                display: inline-block;
                width: 5rem;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }
            .author{
                margin-top: 0.1rem;
                font-size: small;
                color: gray;
            }
        }
        .icons{
            display: flex;
            gap: 0.1rem;
            position: absolute;
            right: 0.3rem;
        }
    }
</style>